package curd

import (
    "github.com/gin-gonic/gin"
    // "go.uber.org/zap"
	// "goskeleton/app/global/variable"
	"goskeleton/app/model/customer"

)

func CreateCustomerCurdFactory() *CustomerCurd { 
	return &CustomerCurd{CustomerModel: customer.CreateCustomerFactory("")} 
}

type CustomerCurd struct {
	CustomerModel *customer.CustomerModel
}

func (e *CustomerCurd) InsertData(c *gin.Context) bool { 
	return e.CustomerModel.InsertData(c)
}

func (e *CustomerCurd) UpdateData(c *gin.Context) bool { 
	return e.CustomerModel.UpdateData(c)
}

func (e *CustomerCurd) ListData(limits, limitItems int,order string, name string, company string, customerStatus int)(totalCounts int64, tmp []*customer.CustomerModel) { 
	return e.CustomerModel.ListData(limits, limitItems,order, name, company, customerStatus)
}

func (e *CustomerCurd) ShowOneItem(id int)(tmp *customer.CustomerModel) { 
	return e.CustomerModel.ShowOneItem(id)
}

func (e *CustomerCurd) GetCustomerByIds(ids []int)(tmp []*customer.CustomerModel) {
	return e.CustomerModel.GetCustomerByIds(ids)
}

func (e *CustomerCurd) GetCustomerIdAndNameAllData() (tmp []map[string]any) {
	field := []string{"id", "name"}
	totalCounts,res := e.CustomerModel.GetCustomerAllData(field)
	if totalCounts == 0 || res == nil {
		return nil
	}
	for _,v := range res{
		tmp = append(tmp,map[string]any{
			"id": v.Id,
			"name": v.Name,
		})
	}
	return tmp
}

func (e *CustomerCurd) GetTotalStatusStatistics() (totalStatusStatistics *customer.TotalStatusStatistics) {
	return e.CustomerModel.GetTotalStatusStatistics()
}

func (e *CustomerCurd) DeleteData(id int) bool {
	return e.CustomerModel.DeleteData(id)
}

